package com.yan.deezer.ui.fragment;

import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.actionbarsherlock.app.SherlockFragment;
import com.yan.deezer.R;

public class DeezerHomeFragment extends SherlockFragment {
	int mNum;

	/**
	 * Create a new instance of DeezerHomeFragment, providing "num" as an
	 * argument.
	 */
	public static DeezerHomeFragment newInstance(int num) {
		DeezerHomeFragment f = new DeezerHomeFragment();

		// Supply num input as an argument.
		Bundle args = new Bundle();
		args.putInt("num", num);
		f.setArguments(args);

		return f;
	}

	/**
	 * When creating, retrieve this instance's number from its arguments.
	 */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setHasOptionsMenu(true);

		mNum = getArguments() != null ? getArguments().getInt("num") : 1;
	}

	/**
	 * The Fragment's UI is just a simple text view showing its instance number.
	 */
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		View v = inflater.inflate(R.layout.hello_deezer_fake_home, container,
				false);

		ImageView fakeHome = (ImageView) v.findViewById(R.id.hello_deezer);
		fakeHome.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				showDialog();
			}
		});

		return v;
	}

	@Override
	public void onActivityCreated(Bundle savedInstanceState) {

		super.onActivityCreated(savedInstanceState);
		setHasOptionsMenu(true);

	}

	// ////////////////////////////////////////YAN's Personal Information:

	public void showDialog() {
		DialogFragment newFragment = MyAlertDialogFragment
				.newInstance(R.string.alert_dialog_title);
		newFragment.show(getFragmentManager(), "dialog");
	}

}